Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Aug 28, 2025

Summary

Updates the OpenRouter integration to support the new API response format with separate input_modalities and output_modalities arrays, replacing the single modality field. Also adds comprehensive filtering to exclude image generation models from all model lists.

Changes

Core Updates

  • Schema Changes: Updated openRouterArchitectureSchema to use input_modalities and output_modalities arrays
  • Function Signatures: Modified parseOpenRouterModel to accept separate inputModality and outputModality parameters
  • Image Support Detection: Updated logic to use input_modalities array for determining image input support

Filtering Implementation

Added filtering across all OpenRouter model fetchers to exclude image generation models (models with 'image' in output_modalities):

  • src/api/providers/fetchers/openrouter.ts - Core fetcher functions
  • webview-ui/src/components/ui/hooks/useOpenRouterModelProviders.ts - WebView UI hook
  • apps/web-roo-code/src/lib/hooks/use-open-router-models.ts - Web app hook

Testing

  • Updated all test cases to use new parameter format
  • Added test coverage for filtering functionality
  • All existing tests continue to pass

Impact

  • ✅ Supports new OpenRouter API format with separate input/output modalities
  • ✅ Filters out image generation models from all model lists
  • ✅ Maintains backward compatibility and existing functionality
  • ✅ Preserves type safety throughout the codebase

This ensures users only see relevant text-based language models and not image generation models in the model selection UI.

…lter image generation models

- Updated openRouterArchitectureSchema to use input_modalities and output_modalities arrays
- Modified parseOpenRouterModel to accept separate inputModality and outputModality parameters
- Updated image support detection to use input_modalities array
- Added comprehensive filtering to exclude image generation models (models with 'image' in output_modalities)
- Applied filtering across all OpenRouter model fetchers:
  - src/api/providers/fetchers/openrouter.ts
  - webview-ui/src/components/ui/hooks/useOpenRouterModelProviders.ts
  - apps/web-roo-code/src/lib/hooks/use-open-router-models.ts
- Updated all tests to use new modality format
- Added test coverage for filtering functionality

This ensures we only show text-based language models and exclude image generation models from model lists.
@github-actions
Copy link
Contributor

🚀 Preview deployed!

Your changes have been deployed to Vercel:

Preview URL: https://roo-code-website-8cg9vurtc-roo-code.vercel.app

This preview will be updated automatically when you push new commits to this PR.

Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I've reviewed the changes and they properly implement the migration from single modality to separate input_modalities and output_modalities arrays. The filtering of image generation models is consistently applied across all fetchers. I have some suggestions for improvement.

Additional observations:

  • There's still a hardcoded modalities: ["image", "text"] field in src/api/providers/openrouter.ts line 305 in the generateImage method that might need updating for consistency
  • Consider extracting the duplicate filtering logic into a shared utility function for better maintainability


return result.data.data
.filter((rawModel) => {
// Skip image generation models (models that output images)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment here explaining why image generation models are being filtered out. This would help future maintainers understand the business logic behind this decision.

Suggested change
// Skip image generation models (models that output images)
.filter((rawModel) => {
// Skip image generation models (models that output images)
// We only want text-based language models in the model selection UI
return !rawModel.architecture?.output_modalities?.includes("image")
})

}

// Model with image output should be filtered out - we only test parseOpenRouterModel
// since the filtering happens in getOpenRouterModels/getOpenRouterModelEndpoints
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good test coverage for the parseOpenRouterModel function! Since the filtering happens at a higher level in getOpenRouterModels and getOpenRouterModelEndpoints, would it be valuable to add integration tests that verify the filtering behavior actually excludes image generation models from the returned results?

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 28, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request lgtm This PR has been approved by a maintainer labels Aug 28, 2025
@mrubens mrubens merged commit 8e66607 into main Aug 28, 2025
28 of 29 checks passed
@mrubens mrubens deleted the feat/openrouter-input-output-modalities branch August 28, 2025 14:19
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 28, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants